详解激活函数Mish 您所在的位置:网站首页 yolov4 mish激活函数 详解激活函数Mish

详解激活函数Mish

2023-10-29 05:42| 来源: 网络整理| 查看: 265

激活函数Mish   对YOLO有了解的或者从事人工智能的相关人员,都知道前段时间yolov4出来了,而且相对于yolov3在精度上有一个质的飞跃,让人感觉匪夷所思,于是在好奇心的驱使下,了解了一下yolov4;与yolov3相比较,主要有几个不同点:网络层更深了、激活函数将leakyRelu替换为mish、采用了SPP(空间金字塔池化)等。下面主要学习一下激活函数mish:   在论文“ Mish: A Self Regularized Non-Monotonic Neural Activation Function”中, Diganta Misra有这样的描述:“Over the years of theoretical research, many activation functions have been proposed, however, only a few are widely used in mostly all applications which include ReLU (Rectified Linear Unit), TanH (Tan Hyperbolic), Sigmoid, Leaky ReLU and Swish. ” 和 “For instance, in Squeeze Excite Net- 18 for CIFAR 100 classification, the network with Mish had an increase in Top-1 test accuracy by 0.494% and 1.671% as compared to the same network with Swish and ReLU respectively”。大概意思是,现在仍被广泛应用的激活函数有ReLU、TanH、Sigmoid、Leaky ReLU 和 Swish;而在这篇论文中,提出了一个新的激活函数Mish,并且经过验证得出一个结论mish的精度比Swish高0.494%,比ReLU高1.671%。 Mish的公式: f ( x ) = x ∗ t a n h ( s o f t p l u s ( x ) ) f(x)=x*tanh(softplus(x)) f(x)=x∗tanh(softplus(x)) Mish公式分步合并:

Mish的输入数据为x 1. softplus: y1 = ln(1+e^x) 2. tanh: y2 = (e^y1 - e^(y1 * -1)) / (e^y1 - e^(y1 * -1)) 3. Mish: y = y2 * x

下图为,Mish和其他常用的激活函数的函数对比,从中可以总结出Mish和Swish比较相似的: 在这里插入图片描述

常见激活函数对比

下图主要说明了,经过ReLU、Swish、Mish三个不同激活函数后的输出对比,从中可以发现Mish相对于ReLU、Swish显得更加平滑一些。 在这里插入图片描述

ReLU、Swish、Mish的结果对比

在这里插入图片描述

Mish的属性

代码事例

import numpy as np import matplotlib.pyplot as plt def mish_fun(x): tmp = np.log(1 + np.exp(x)) tmp = np.tanh(tmp) tmp = tmp * x return tmp if __name__ == '__main__': input = np.array([-15, -11, -10.5, -10, -4.5, -4, -3.5, -3, -2.5, -2, -1.5, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10.5]) output = mish_fun(input) plt.plot(input, output) plt.show() print(input) print(output)

在这里插入图片描述

Mish激活函数


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有